//定义当前关卡
var gameLevel = 0;
//定义所有关卡数组
var maps = new Array();
//恒定英雄名字
var heroName;
//定义英雄
var HERO = new Object();
//定义按下方向键下一坐标的位置
var heroNextPoint = new Object();
//定义火球初始坐标
var ballNextPoint;
//定义hero火球数组
var userFireBallArray = new Array();
//定义怪物数组
var monsterArray = new Array();
//定义怪物火球数组
var monsterFireBallArray = new Array();
//显示信息div
var INFODIV = document.getElementById("test");
//开始音乐
var startVideo = document.getElementById("startVideo");
//选择英雄音乐
var selectHeroVideo = document.getElementById("selectHeroVideo");
//开场音乐播放
startVideo.play();

function showStart(){
	initMap();
//	$("#startView").fadeOut(100);
//	$("#selectHero").slideDown(500);
//	startVideo.pause();
//	selectHeroVideo.play();
	mainCartoon();
}

function selectHero(hero){
	HERO.name = hero;
	heroName = hero;
	HERO.x = 0;
	HERO.y = 0;
	if(HERO.name == 'hero1'){
		HERO.Blood = 2;
		HERO.FireSpeed = 50;
	}else if(HERO.name == 'hero2'){
		HERO.Blood = 5;
		HERO.FireSpeed = 120;
	}else if(HERO.name == 'hero3'){
		HERO.Blood = 4;
		HERO.FireSpeed = 90;
	}else if(HERO.name == 'hero4'){
		HERO.Blood = 3;
		HERO.FireSpeed = 70;
	}
	HERO.initBlood = HERO.Blood;
	$("#selectHero").fadeOut(100);
	setMainMap(maps[gameLevel],hero);
}

function setMainMap(MAP,hero){
	var mian = document.getElementById("mainView");
	var msg="";
	for(var i = 0;i<MAP.length;i++){
		for(var j = 0;j<MAP[i].length;j++){
			if(MAP[i][j] == 9){
				HERO.x = i;
				HERO.y = j;
				msg+="<img src='img/gameViewIMG/"+hero+".jpg' id='"+i+" "+j+"' width='50px' height='50px'>";
			}else{
				msg+="<img src='img/gameViewIMG/flood"+MAP[i][j]+".jpg' id='"+i+" "+j+"' width='50px' height='50px'>";
			}
		}
	}
	
	mian.innerHTML=msg;
	mian.style.display="block";
	INFODIV.style.display="block";
	addMonster(8,500);
}

function setINFO(life,Level,computer){
	document.getElementById("life").innerHTML = life;
	document.getElementById("Level").innerHTML = Level+1;
	document.getElementById("computer").innerHTML = computer;
}

function getByXY(x,y){
	return document.getElementById(x+" "+y);
}